package com.demon.framework.common.model.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 登录类型枚举:1-手机验证码,2-账号密码,3-支付宝,4-微信,5-IOS
 *
 * @author Demon-HY
 * @date 2020/5/21
 */
@Getter
@AllArgsConstructor
public enum LoginTypeEnum {

    /**
     * 手机验证码
     */
    MOBILE_CODE(1, "手机验证码"),

    /**
     * 账号密码
     */
    MOBILE_PWD(2, "账号密码"),

    /**
     * 支付宝
     */
    ALIPAY(3, "支付宝"),

    /**
     * 微信
     */
    WECHAT(4, "微信"),

    /**
     * IOS
     */
    IOS(5, "IOS"),
    ;

    private final Integer type;
    private final String name;

    public static LoginTypeEnum getByType(Integer type) {
        if (type == null) {
            return null;
        }

        for (LoginTypeEnum loginTypeEnum : LoginTypeEnum.values()) {
            if (loginTypeEnum.getType().equals(type)) {
                return loginTypeEnum;
            }
        }

        return null;
    }
}
